package com.example.childrendapp.gamefunny;

import com.example.childrendapp.R;

import android.app.NotificationManager;
import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Binder;
import android.os.IBinder;
import android.widget.Toast;


public class MyGameLocalService extends Service {
	private NotificationManager mNM;
    MediaPlayer mMediaPlayer;
    private final IBinder mBinder = new LocalBinder();
    public class LocalBinder extends Binder {
        MyGameLocalService getService() {
            return MyGameLocalService.this;
        }
    }
    
    @Override
    public void onCreate() {    	
        mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
    }

	@Override
    public void onDestroy() {
        mNM.cancel(R.string.local_service_started);       
        Toast.makeText(this, R.string.local_service_stopped, Toast.LENGTH_SHORT).show();
    }
	public void startNhacNen(){
		mMediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.xedap);
		mMediaPlayer.start();
	}
    
    public void stopMedia() {
    	mMediaPlayer.stop();
    	mMediaPlayer.release();
    }
  
    
    @Override
    public IBinder onBind(Intent intent) {    	    	
        return mBinder;
    }

}
